package com.yifeng.repo.controller.statemachine.fsm.audit.biz;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2024/9/20.
 */
@Getter
@AllArgsConstructor
public enum AuditStateEnum {
    APPLY("APPLY", "已申请"),
    LEVEL_ONE_PASS("1PASS", "一级同意"),
    LEVEL_ONE_REJ("1REJ", "一级不同意"),
    LEVEL_SECOND_PASS("2PASS", "二级同意"),
    LEVEL_SECOND_REJ("2REJ", "二级不同意"),
    LEVEL_THREE_PASS("3PASS", "三级同意"),
    LEVEL_THREE_REJ("3REJ", "三级不同意"),
    LEVEL_FOUR_PASS("4PASS", "四级同意"),
    LEVEL_FOUR_REJ("4REJ", "四级不同意"),
    LEVEL_FIVE_PASS("5PASS", "五级同意"),
    LEVEL_FIVE_REJ("5REJ", "五级不同意"),
    DONE("DONE", "已完成");

    @EnumValue
    @JsonValue
    private final String code;

    private final String name;

    private static final Map<String, AuditStateEnum> mappings = new HashMap<>(8);

    static {
        for (AuditStateEnum value : values()) {
            mappings.put(value.getCode(), value);
        }
    }

    public static AuditStateEnum resolve(String code) {
        return (code != null ? mappings.get(code) : null);
    }
}
